package logic

import (
	"car_srv/models"
	"context"

	"car_srv/car"
	"car_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 用户列表
func (l *UserListLogic) UserList(in *car.UserListRequest) (*car.UserListResponse, error) {
	var user models.User
	user.Status = in.Status
	userList, _ := user.ListStatus()

	var usersList []*car.UserList
	for _, u := range userList {
		list := car.UserList{
			Id:       int64(u.ID),
			Mobile:   u.Mobile,
			Password: u.Password,
		}
		usersList = append(usersList, &list)
	}

	return &car.UserListResponse{
		List: usersList,
	}, nil
}
